package com.ygs.secs.tools;

import java.io.File;
import java.util.Random;

public class CustomTools {
    public static String getRandom4(int len) {
        String source = "0123456789";
        Random r = new Random();
        StringBuilder rs = new StringBuilder();
        for (int j = 0; j < len; j++) {
            rs.append(source.charAt(r.nextInt(10)));
        }
        return rs.toString();
    }

    /**
     * 删除图片文件
     *
     * @param imagepath 文件路径
     * @param mappath   映射路径
     * @param realpath  真实路径映射
     * @return
     */
    public static boolean deliamge(String imagepath, String mappath, String realpath) {
        String replace = imagepath.replace(mappath, "");
//      System.out.println(realpath + replace);
        String realimagpath = realpath + replace;
        File file = new File(realimagpath);
        if (file.exists() && file.isFile()) {
            return file.delete();
        }
        return false;
    }

    public static boolean isEmptyString(Object obj) {
        if (obj!=null){
            return !obj.toString().isEmpty();
        }
        return false;
    }

}
